package my;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@Entity
@Table(name = "book")
@NamedQueries({
		@NamedQuery(name = "findAllBooks", query = "SELECT b FROM Book b"),
		@NamedQuery(name = "updateBook", query = "UPDATE Book b SET b.title = :title WHERE b.isbn = :isbn") })
@XmlRootElement(name = "book")
@XmlAccessorType(XmlAccessType.FIELD)
public class Book implements Serializable {

	private static final long serialVersionUID = -6181409018098734922L;

	@Id
	@XmlElement
	private String isbn;

	@Column(unique = true)
	@XmlElement
	private String title;

	public Book() {
	}

	public Book(String isbn, String title) {
		this.isbn = isbn;
		this.title = title;
	}

	public String getIsbn() {
		return isbn;
	}

	public void setIsbn(String isbn) {
		this.isbn = isbn;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
}
